home *** CD-ROM | disk | FTP | other *** search
/ PC Play 129 / pc play 129.iso / Demo / man2 / man2.exe / data / scripts / bomber_scripts.lua < prev    next >
Encoding:
Text File  |  2006-10-26  |  8.3 KB  |  234 lines

  1.  
  2. function units_bomber_select()
  3.     units_select(12)
  4.     uniGetExecutor():addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_SPOTLIGHT_RED4)
  5. end
  6.  
  7. function units_bomber_unselect()
  8.     units_unselect()
  9.     uniGetExecutor():addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_SPOTLIGHT_RED4)
  10. end
  11.  
  12. function units_bomber_selectenemy()
  13.     uniGetExecutor():addSimpleEffect(ENET_EFFECT_SELECTEDGEOMETRY_ENEMY)
  14. end
  15.  
  16. function units_bomber_damaged()
  17.     uniGetExecutor():applyDamage(uniGetLife())
  18. end
  19.  
  20. function units_bomber_highlight()
  21.     uniGetExecutor():addEffectWithRadius(ENET_EFFECT_GEOMETRY_HIGHLIGHT,15)
  22. end
  23.  
  24. function units_bomber_setup()
  25.     local bomber = uniGetExecutor()
  26.     bomber:setTransformOwner(units_findfreefirespot(uniGetTarget(),1))
  27.     bomber:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_SPOTLIGHT_GREEN4):setLocalPosition(-7,4,-10)
  28.     bomber:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_SPOTLIGHT_GREEN4):setLocalPosition(7,4,-10)
  29.  
  30.     bomber:setLocalPosition(0,0,0)
  31.     units_reloadfirespots(bomber,1,ENET_EFFECT_BULLET_BOMB)
  32.     bomber:resetAnimations()
  33.     bomber:setVisibility(true,true)
  34.     bomber:addSimpleEffect(ENET_EFFECT_BOUNDEDTEXT)
  35.     bomber:addSimpleEffect(ENET_EFFECT_GEOMETRY_AIRSHADOW2)
  36. end
  37.  
  38. function units_bomber_fire()
  39.     local unit = uniGetExecutor()
  40.     local base = unit:getTransformOwner()
  41.     local target = uniGetTarget()
  42.  
  43.     uniSetLife(uniGetLife() / 4.0)
  44.  
  45.     local holders = {}
  46.     holders[0] = enHolder:new(target)
  47.     holders[1] = enHolder:new(base,HT_CARGOSPACE)
  48.  
  49.     unit:setTransformOwner()
  50.  
  51.     local enginePS = {}
  52.     enginePS[0] = unit:getBone(ENBT_STEPEMITTER,0):addSimpleEffect(ENET_EFFECT_PS_AIRTRAY)
  53.     enginePS[1] = unit:getBone(ENBT_STEPEMITTER,1):addSimpleEffect(ENET_EFFECT_PS_AIRTRAY)
  54.     enginePS[2] = unit:addSimpleEffect(ENET_EFFECT_PS_AIRENGINE)
  55.  
  56.     unit:addAnimationToQueue(ENAT_PREPAREFORFIRE1,1)
  57.     unit:addAnimationToQueue(ENAT_GO,MATH_INFINITY)
  58.  
  59.     local sound = unit:play3DSound("air_move.wav",1)
  60.  
  61.     waitDeath(unit:addMoveEffect(ENET_EFFECT_MOVE_AIRSMOOTH,100,uniGetTarget()))
  62.  
  63.     local firespots = {}
  64.     firespots[0] = unit:getBone(ENBT_FIRE1,0)
  65.     firespots[1] = unit:getBone(ENBT_FIRE1,1)
  66.  
  67.     local mover = unit:addMoveEffect(ENET_EFFECT_MOVE_AIRSMOOTH,100,base)
  68.     holders[3] = enHolder:new(mover);
  69.  
  70.     firespots[0]:findEffect(ENET_EFFECT_BULLET_BOMB):executeCommand(ENC_FIRE1)
  71.     pause(0.1)
  72.     firespots[0]:addSimpleEffect(ENET_EFFECT_BULLET_BOMB)
  73.     firespots[1]:findEffect(ENET_EFFECT_BULLET_BOMB):executeCommand(ENC_FIRE1)
  74.     pause(0.1)
  75.     firespots[1]:addSimpleEffect(ENET_EFFECT_BULLET_BOMB)
  76.     firespots[0]:findEffect(ENET_EFFECT_BULLET_BOMB):executeCommand(ENC_FIRE1)
  77.     pause(0.1)
  78.     firespots[0]:addSimpleEffect(ENET_EFFECT_BULLET_BOMB)
  79.     firespots[1]:findEffect(ENET_EFFECT_BULLET_BOMB):executeCommand(ENC_FIRE1)
  80.     pause(0.1)
  81.     firespots[1]:addSimpleEffect(ENET_EFFECT_BULLET_BOMB)
  82.  
  83.     waitDeath(mover)
  84.  
  85.     enginePS[0]:suspendedDestroy(2.0);
  86.     enginePS[1]:suspendedDestroy(2.0);
  87.     enginePS[2]:suspendedDestroy(0.5);
  88.  
  89.     waitDeath(unit:addRotationEffect(ENET_EFFECT_ROTATE_AIRHORIZONTALORIENT,1.57))
  90.     unit:setCurrentAnimationRepeatCount(1)
  91.     unit:addAnimationToQueue(ENAT_AFTERFIRE1,1)
  92.     waitDeath(unit:addMoveEffect(ENET_EFFECT_MOVE_LINEARFLYTOOWNER,100,base))
  93.  
  94.     unit:setTransformOwner(base)
  95.     sound:destroy()
  96.  
  97.     unit:addFireArrow()
  98. end
  99.  
  100. function units_bomber_move()
  101.     local bomber = uniGetExecutor()
  102.     bomber:setTransformOwner()
  103.     local holder = enHolder:new(uniGetTarget())
  104.     local base = units_findfreefirespot(uniGetTarget(),1)
  105.     local placeHolder = enHolder:new(base,HT_CARGOSPACE)
  106.  
  107.     local enginePS = {}
  108.     enginePS[0] = bomber:getBone(ENBT_STEPEMITTER,0):addSimpleEffect(ENET_EFFECT_PS_AIRTRAY)
  109.     enginePS[1] = bomber:getBone(ENBT_STEPEMITTER,1):addSimpleEffect(ENET_EFFECT_PS_AIRTRAY)
  110.     enginePS[2] = bomber:addSimpleEffect(ENET_EFFECT_PS_AIRENGINE)
  111.  
  112.     bomber:addAnimationToQueue(ENAT_PREPAREFORFIRE1,1)
  113.     bomber:addAnimationToQueue(ENAT_GO,MATH_INFINITY)
  114.  
  115.     local sound = bomber:play3DSound("air_move.wav",1)
  116.  
  117.     waitDeath(bomber:addMoveEffect(ENET_EFFECT_MOVE_AIRSMOOTH,100,base))
  118.  
  119.     sound:destroy()
  120.     bomber:play3DSound("air_stop.wav",0):destroy()
  121.  
  122.     enginePS[0]:suspendedDestroy(2.0);
  123.     enginePS[1]:suspendedDestroy(2.0);
  124.     enginePS[2]:suspendedDestroy(0.5);
  125.  
  126.     waitDeath(bomber:addRotationEffect(ENET_EFFECT_ROTATE_AIRHORIZONTALORIENT,1.57))
  127.     bomber:setCurrentAnimationRepeatCount(1)
  128.     bomber:addAnimationToQueue(ENAT_AFTERFIRE1,1)
  129.     waitDeath(bomber:addMoveEffect(ENET_EFFECT_MOVE_LINEARFLYTOOWNER,100,base))
  130.     bomber:setTransformOwner(base)
  131. end
  132.  
  133. function units_bomber_explode()
  134.     local bomber = uniGetExecutor()
  135.     bomber:setTransformOwner()
  136.     bomber:play3DSound("bigunitexplode.wav",0):destroy()
  137.     local ps_explode = bomber:addSimpleEffect(ENET_EFFECT_PS_BOMBEREXPLODE)
  138.     ps_explode:setTransformOwner()
  139.     pause(0.5)
  140.     bomber:setVisibility(false,false)
  141.     pause(0.5)
  142.     ps_explode:suspendedDestroy(6.5)
  143.  
  144. end
  145.  
  146. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_SETUP,"units_bomber_setup")
  147. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_RESETUP,"units_bomber_setup")
  148. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_FIRE1,"units_bomber_fire")
  149. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_FIRE2,"units_bomber_fire")
  150. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_MOVE,"units_bomber_move")
  151. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_EXPLODE,"units_bomber_explode")
  152. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_SELECT,"units_bomber_select")
  153. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_SELECTENEMY,"units_bomber_selectenemy")
  154. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_UNSELECT,"units_bomber_unselect")
  155. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_DAMAGED,"units_bomber_damaged")
  156. registerCommand(ENSCRIPTSET_BULLET_AIR,ENC_HIGHLIGHT,"units_bomber_highlight")
  157.  
  158.  
  159. -- make description of unit
  160. desc = getEffectDescriptionP(ENET_UNIT_AIR)
  161. desc.ClassID = ENCLASS_MESHINSTANCE
  162. desc.EffectClassType = ENECT_GEOMETRY
  163. desc.FileName = "air.rmd"
  164. desc.ScriptSet = ENSCRIPTSET_BULLET_AIR
  165. desc.MoveType = ENMOVE_FLY
  166. desc.RenderType = ENRENDERTYPE_GEOMETRY
  167. desc.Material = ENMAT_RIGIDSKINNEDMESH
  168. desc.MaterialColors = units_materialcolors_human
  169.  
  170. -- shadow
  171. desc = getEffectDescriptionP(ENET_EFFECT_GEOMETRY_AIRSHADOW2)
  172. desc.ClassID = ENCLASS_MESHINSTANCE
  173. desc.EffectClassType = ENECT_GEOMETRY
  174. desc.FileName = "air_shadow.rmd"
  175. desc.RenderType = ENRENDERTYPE_SHADOW
  176. desc.Material = ENMAT_SHADOW
  177. desc.MaterialColors = units_materialcolors_shadow
  178.  
  179. -- register new unit to logic
  180. unitDesc = logic_getUnitDescP(11)
  181. unitDesc.group = 2
  182. unitDesc.order = 4
  183. unitDesc.unit_res_id = ENET_UNIT_AIR
  184. unitDesc.unit_icon_id = "Air_h_small_normal.dds"
  185. unitDesc.active_id = "Air_h_small_active.dds"
  186. unitDesc.pressed_id = "Air_h_small_pressed.dds"
  187. unitDesc.big_icon_id = "Air_h_big_normal.dds"
  188. unitDesc.small_icon_id = "Fighter_u_stats.dds"
  189. unitDesc.HP = 1
  190. unitDesc.MP = 120
  191. unitDesc.WR = 6
  192. unitDesc.min_WR = 1
  193. unitDesc.WD = 1
  194. unitDesc.WR2 = 0
  195. unitDesc.min_WR2 = 0
  196. unitDesc.WD2 = 0
  197. unitDesc.ability = 4
  198. unitDesc.transport = 0
  199. unitDesc.value = 3
  200. unitDesc.race = 0
  201. unitDesc.fire_pause = 10.0
  202. unitDesc.move_pause = 10.0
  203. unitDesc.unit_info_scale = 0.10
  204. unitDesc.scn_name = "AIR"
  205.  
  206. ------------------------------------------------------------------------------------------------------
  207. ------------------------ effects related to unit------------------------------------------------------
  208. ------------------------------------------------------------------------------------------------------
  209.  
  210. function bullets_bomb_fire()
  211.     local bullet = uniGetExecutor()
  212.     bullet:setTransformOwner()
  213.     local sound = bullet:play3DSound("air_bomb_fly.wav",0)
  214.     waitDeath(bullet:addMoveEffect(ENET_EFFECT_MOVE_FALLTOGROUND,100,uniGetTarget()),100)
  215.     sound:destroy()
  216.     bullet:setVisibility(false,true)
  217.     local hitType = bullet:getLastMovementEndType();
  218.     if(hitType == ENBHT_DIRECTHIT) then
  219.         bullet:addSimpleEffect(ENET_EFFECT_PS_BATTLESHIPSHOTHIT):suspendedDestroy(2.0)
  220.         bullet:play3DSound("air_bomb_directhit.wav",0):destroy()
  221.     elseif(hitType == ENBHT_GROUNDHIT) then
  222.         bullet:addSimpleEffect(ENET_EFFECT_PS_BOMB_EARTHHIT):suspendedDestroy(2.0)
  223.         bullet:play3DSound("air_bomb_earthhit.wav",0):destroy()
  224.     elseif(hitType == ENBHT_WATERHIT) then
  225.         bullet:addSimpleEffect(ENET_EFFECT_PS_BOMB_WATERHIT):suspendedDestroy(2.0)
  226.         bullet:play3DSound("air_bomb_waterhit.wav",0):destroy()
  227.     end
  228.     uniGetTarget():executeCommand(ENC_DAMAGED)
  229.     pause(2.0)
  230.     bullet:destroy()
  231. end
  232.  
  233. registerCommand(ENSCRIPTSET_BULLET_BOMB,ENC_FIRE1,"bullets_bomb_fire")
  234.